import { Injectable } from '@angular/core';
import { Observable, Subject } from 'rxjs';
import { CoreModule } from '../core.module';
import { LayoutRouteStatus } from 'src/app/components/breadcrumb/breadcrumb.component';

@Injectable({
    providedIn: CoreModule
})
export class MessageService {
    private subject = new Subject<any>();
    private breadSubject = new Subject<any>();
    constructor(
    ) { }
    setBreadcrumb(layoutRouteStatus: LayoutRouteStatus) {
        this.breadSubject.next(layoutRouteStatus);
    }
    getBreadcrumb(): Observable<any> {
        return this.breadSubject.asObservable();
    }
    clearMessage() {
        if (this.subject.observers.length > 2) {
            for (let i = 0; i < this.subject.observers.length - 2; i++) {
                this.subject.observers.splice(i, 1);
            }
        }
    }
    sendMessage(message: string,data) {
        this.subject.next({ text: message,data });
    }
    getMessage(): Observable<any> {
        return this.subject.asObservable();
    }
    // 错误提示
    showErrorMsg(message:string){
        
    }
}


